<template>
  <div class="home">
    <header class="header">
      <img style src="/static/icon/logo.png" alt />
      <p>利佳</p>

      <van-field class="input" left-icon="search" v-model="value" placeholder="请输入用户名" />
      <div>
        <img src="/static/icon/msg.png" alt />
        <span>消息</span>
      </div>
    </header>
    <van-swipe class="swipe" :autoplay="3000" indicator-color="#06A44F">
      <van-swipe-item v-for="(item, key) in bannerList" :key="key">
        <a :href="item.link">
          <img :src="item.image" />
        </a>
      </van-swipe-item>
    </van-swipe>
    <home-img></home-img>
    <section class="img">
      <div class="bottom">
        <a href="https://scancode.mashangfangxin.com/view/trace-code-drug-page/vaccine_recall/queryInfo?from=groupmessage">
        <img src="/static/icon/kuaicha.png" alt srcset />
        </a>
      </div>
    </section>
    <section class="intro">
      <div class="title">
        <div>
          <span>利佳健康平台简介</span>
        </div>
      </div>
      <div
        class="content"
      >2016年，利佳健康服务有限公司于香港成立，利佳与香港各大私立医院及大型医疗机构、境外医疗机构达成长期战略合作关系，为境内外华人提供全球最好的香港医疗服务。利佳在港合作医疗机构达37家，合作专科医生高达595个，几乎涵盖医学各个领域学科。</div>
      <van-row class="introImg" gutter="2">
        <img src="/static/img/home-intro-img.png" />
      </van-row>
    </section>
    <section class="advantage">
      <div class="title">
        <div>
          <span>利佳健康平台优势</span>
        </div>
      </div>
      <div>
        <div class="content">
          <div class="left">
            <img src="/static/icon/advantage.png" alt />
            <p>1</p>
          </div>
          <div class="right">
            <p>收费明细透明</p>
            <div class="detail">平台规范收费，所有费用公正透明，杜绝任何乱收费、隐形消费问题。</div>
          </div>
        </div>
        <div class="content">
          <div class="left">
            <img src="/static/icon/advantage.png" alt />
            <p>2</p>
          </div>
          <div class="right">
            <p>多个合作医疗机构</p>
            <div class="detail">香港岛、新界及九龙等香港各个地区皆有合作医疗机构，总数达37个。</div>
          </div>
        </div>
        <div class="content">
          <div class="left">
            <img src="/static/icon/advantage.png" alt />
            <p>3</p>
          </div>
          <div class="right">
            <p>医疗机构权威性</p>
            <div class="detail">所合作的医疗机构（医院）皆为香港数一数二的医疗机构，医疗设备都是世界先进水平。</div>
          </div>
        </div>
        <div class="content">
          <div class="left">
            <img src="/static/icon/advantage.png" alt />
            <p>4</p>
          </div>
          <div class="right">
            <p>合作权威医生众多</p>
            <div class="detail">从精神学科到肿瘤学科，几乎全医学领域的权威医生与利佳皆有合作关系，合作医生多大595个。</div>
          </div>
        </div>
      </div>
    </section>
    <section class="hospital">
      <div class="title">
        <div>
          <span>合作医院介绍</span>
        </div>
        <a href="aa" class="show-more">
          查看更多
          <div></div>
        </a>
      </div>
      <div>
        <ul>
          <li v-for="(val,key) in hospitalPartner" :key="key">
            <div class="content">
              <img :src="val.img_url" alt />
              <p>{{val.y_name}}</p>
              <div>{{val.y_desc}}</div>
            </div>
          </li>
        </ul>
      </div>
    </section>
    <section class="partner">
      <div class="title">
        <div>
          <span>合作机构</span>
        </div>
      </div>
      <van-row class="top" gutter="2">
        <van-col class="item" v-for="(val,key) in brandPartner" :key="key" span="8">
          <div class="img-div">
            <img :src="val.icon" alt />
          </div>
          <p>{{val.name}}</p>
        </van-col>
      </van-row>
    </section>
    <section class="message">
      <div class="title">
        <div>
          <span @click="clickMessage(1)" :class="active1">最新资讯</span>
          <span @click="clickMessage(2)" :class="active2" style=" margin-left: 15px;">健康指南</span>
        </div>
        <a href="aaa">
          查看更多
          <img src="/static/icon/goto.png" />
        </a>
      </div>
      <ul class="msgList" v-if="active1 == 'active'">
        <li v-for="(item,key) in list" :key="key">
          <p>{{item.title}}</p>
          <div>{{item.time}}</div>
        </li>
      </ul>
      <ul class="msgList" v-else>
        <li v-for="(item,key) in list" :key="key">
          <p>{{item.title}}</p>
          <div>{{item.time}}</div>
        </li>
      </ul>

      <!-- <van-list v-if="active1 == 'active'" v-model="loading" :finished="finished" @load="onLoad">
        <van-cell
          v-for="(item,key) in list"
          :key="key"
          :title="item.title"
          @click="tolLink(item.link)"
        />
      </van-list>
      <van-list v-else v-model="loading" :finished="finished" @load="onLoad">
        <van-cell
          v-for="(item,key) in list"
          :key="key"
          :title="item.title"
          @click="tolLink(item.link)"
        />
      </van-list>-->
    </section>
    <div style="padding-bottom:3.125rem">
      <contact-footer v-show="false"></contact-footer>
    </div>
    <img @click="backToTop" class="goToTop" src="/static/icon/top.png" alt />
    <img @click="show = true" class="medicalBox" src="/static/icon/medicalBbox.png" alt />
    <van-popup v-model="show">
      <div class="treasureChest">
        <van-row>
          <van-col class="xunwenyisheng" span="8">
            <img src="/static/icon/xunwenyisheng.png" alt />
            <p>在线询医</p>
          </van-col>
          <van-col class="service" span="8">
            <img src="/static/icon/service.png" alt />
            <p>客户服务</p>
          </van-col>
          <van-col class="hebao" span="8">
            <img src="/static/icon/hebao.png" alt />
            <p>人工核保</p>
          </van-col>
        </van-row>
      </div>
    </van-popup>
  </div>
</template>

<script>
import ContactFooter from "@/components/footer/contactFooter";
import HomeImg from "@/components/homeImg/homeImg";

export default {
  components: {
    ContactFooter,
    HomeImg
  },
  name: "Home",
  data() {
    return {
      show: false,
      list: [],
      value: "",
      hospitalPartner: [],
      brandPartner: [],
      bannerList: [],
      active2: "notActive",
      active1: "active",
      res: {
        code: 1,
        data: {
          // 头部
          head: {
            // 幻灯片
            banner: [
              {
                link: "超链接",
                image: "/static/icon/headerImg.png"
              },
              {
                link: "超链接",
                image: "/static/icon/headerImg.png"
              },
              {
                link: "超链接",
                image: "/static/icon/headerImg.png"
              },
              {
                link: "超链接",
                image: "/static/icon/headerImg.png"
              }
            ],
          },
          // 其他
          other: {
            // 合作医院
            hospital: [
              {
                id: "10",
                y_name: "养和医院", // 显示
                y_desc:
                  "医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍医院介绍", // 显示
                img_url: "/static/icon/headerImg.png", // 显示 需要设置全局的域名 例如：src=static_domain+img_url
                province: "33",
                city: "395",
                district: "3376",
                addr: "港岛跑马地山村道2－4号",
                sort: "1" // 排序 优先显示小的
              },
              {
                id: "3",
                y_name: "播道医院",
                y_desc: "医院介绍",
                img_url: "/static/icon/headerImg.png",
                province: "33",
                city: "395",
                district: "3369",
                addr: "九龙亚皆老街222号",
                sort: "2"
              }
            ],
            // 合作机构
            brand: [
              {
                name: "名字名字名字名字名字名字名字",
                icon: "/static/icon/kangjian.png"
              },
              { name: "名字1", icon: "/static/img/register-logo.png" },
              { name: "名字2", icon: "/static/icon/kangjian.png" },
              { name: "名字", icon: "/static/icon/kangjian.png" },
              { name: "名字1", icon: "/static/icon/kangjian.png" }
            ],
            // 最新咨询
            news: [
              {
                id: 1,
                title:
                  "咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题咨询标题",
                link: "超链接",
                time: "2019/01/02"
              },
              {
                id: 1,
                title: "咨询标题",
                link: "超链接",
                time: "unix 时间戳/秒"
              }
            ],
            // 健康咨询
            health: [
              {
                id: 1,
                title: "咨询标题",
                link: "超链接",
                time: "unix 时间戳/秒"
              }
            ]
          }
        },
        msg: "提示消息,一般发生了错误code=0时显示"
      },
      interval: null
    };
  },
  mounted() {
    this.bannerList = this.res.data.head.banner;
    this.hospitalPartner = this.res.data.other.hospital;
    this.brandPartner = this.res.data.other.brand;
    this.list = this.res.data.other.news;
    console.log(this.list);
  },
  methods: {
    backToTop() {
      let distanceY = window.pageYOffset;
      let i = 0;
      this.interval = setInterval(() => {
        let next = Math.floor(
          this.easeInOutQuad(10 * i, distanceY, -distanceY, 500)
        );
        if (next <= 0) {
          window.scrollTo(0, 0);
          clearInterval(this.interval);
        } else {
          window.scrollTo(0, next);
        }
        i++;
      }, 17);
    },
    easeInOutQuad(t, b, c, d) {
      // 判断当前时间是否总在总时间的一半以内，是的话执行缓入函数，否则的话执行缓出函数
      if ((t /= d / 2) < 1) {
        return (c / 2) * t * t + b;
      } else {
        // 将总长度设置为一半，并且时间从当前开始递减，对图像进行垂直向上平移
        return (-c / 2) * (--t * (t - 2) - 1) + b;
      }
    },
    clickMessage(val) {
      if (val === 1) {
        this.active1 = "active";
        this.active2 = "notActive";
      } else {
        this.active1 = "notActive";
        this.active2 = "active";
      }
    },
    tolLink(link) {
      window.location.href = link;
    }
  }
};
</script>
<style lang='scss' scoped>
.home {
  .header {
    position: absolute;
    top: 0;
    background: rgb(27, 162, 83);
    width: 320px;
    height: 42px;
    img {
      position: relative;
      top: 12px;
      left: 8px;
      width: 18px;
      height: 19px;
    }
    p {
      width: 70px;
      position: relative;
      top: -10px;
      left: 32px;
      margin: 0;
      font-size: 13px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
    }
    .input {
      padding: 2px 5px;
      width: 207px;
      height: 25px;
      border-radius: 25px;
      position: absolute;
      top: 9px;
      left: 73px;
    }
    div {
      img {
        width: 15px;
        height: 15px;
        position: absolute;
        top: 9px;
        left: 293px;
      }
      span {
        position: absolute;
        top: 28px;
        left: 294px;
        font-size: 7px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .swipe {
    width: 305px;
    height: 132px;
    margin-top: 49px;
    margin-left: 7.5px;
    img {
      width: 305px;
      height: 132px;
    }
  }
  .img {
    margin: 0 9px 0 11px;
    width: 300px;
    .bottom {
      height: 51px;
      img {
        width: 300px;
        height: 51px;
      }
    }
  }
  .intro,
  .advantage,
  .hospital,
  .partner,
  .message {
    margin-top: 0px;
    width: 305px;
    margin-left: 7.5px;
    .title {
      height: 32px;
      font-size: 13px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: rgba(27, 162, 83, 1);
      line-height: 32px;
      .active {
        padding-bottom: 6px;
        margin: 0;
        border-bottom: 3px solid rgba(27, 162, 83, 1);
        //
      }
      .notActive {
        color: #000;
        border-bottom: 3px solid rgba(27, 162, 83, 0);
      }
    }
    .content {
      margin-top: 19px;
    }
    .msgList {
      // margin-top: 19px;
      li {
        height: 42px;
        padding-top: 10px;
        border-bottom: 1px solid #f3f1f2;
        p {
          font-size: 13px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: rgba(50, 50, 50, 1);
          margin: 0px 0 5px 0;
          display: -webkit-box;
          /*! autoprefixer: off */
          -webkit-box-orient: vertical;
          /*! autoprefixer: on */
          -webkit-line-clamp: 1;
          overflow: hidden;
        }
        div {
          font-size: 11px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: rgba(153, 153, 153, 1);
        }
      }
    }
  }
  .intro {
    .title {
      padding-top: 10px;
    }
    .introImg {
      img {
        padding-top: 10px;
        width: 303px;
        height: 175px;
      }
    }
    .content {
      text-align: justify;
      text-align-last: left;
      width: 300px;
      font-size: 13px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(102, 102, 102, 1);
      line-height: 19px;
    }
  }
  .intro,
  .advantage,
  .hospital,
  .partner {
    .title {
      position: relative;
    }
    .title > div:before {
      content: "";
      position: absolute;
      left: 20px;
      bottom: -3px;
      right: 8px;
      border-bottom: 3px solid #f3f1f2;
      z-index: 1;
    }
    .title span {
      position: relative;
      z-index: 2;
      padding-bottom: 9px;
      border-bottom: 3px solid rgba(27, 162, 83, 1);
    }
  }
  .message {
    position: relative;
    .title {
      margin-top: 10px;
      margin-bottom: 10px;
      position: relative;
    }
    .title > div:before {
      content: "";
      position: absolute;
      left: 0px;
      bottom: 0px;
      right: 8px;
      border-bottom: 3px solid #f3f1f2;
      z-index: 1;
    }
    .title span {
      position: relative;
      z-index: 2;
      padding-bottom: 9px;
      border-bottom: 3px solid rgba(27, 162, 83, 1);
    }
    .title a {
      position: absolute;
      right: 8px;
      top: 8px;
      font-size: 11px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(126, 126, 126, 1);
      line-height: 16px;
      img {
        position: relative;
        top: 2px;
        width: 8px;
        height: 12px;
      }
    }
  }
  .advantage {
    .title {
      padding-top: 18px;
    }
    .content {
      margin-top: 17px;
      height: auto;
      .left {
        position: relative;
        height: 45px;
        width: 39px;
        float: left;
        img {
          position: relative;
          top: 6px;
          width: 27px;
          height: 27px;
        }
        p {
          position: absolute;
          margin: 0;
          top: 16px;
          left: 11px;
          font-size: 9px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          color: rgba(255, 255, 255, 1);
          line-height: 1em;
        }
      }
      .right {
        p {
          font-size: 12px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: rgba(71, 71, 71, 1);
          margin: 0;
        }
        .detail {
          padding-top: 4px;
          width: 265px;
          margin-left: 40px;
          font-size: 10px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: rgba(126, 126, 126, 1);
          line-height: 16px;
        }
      }
    }
  }
  .hospital {
    .title {
      margin-top: 34px;
    }
    ul {
      width: 100%;
      display: flex;
      overflow: auto;
      li {
        margin-right: 16px;
        .content {
          position: relative;
          width: 213px;
          height: 248px;
          p {
            margin: 0;
            position: absolute;
            left: 0;
            top: 145px;
            font-size: 12px;
            font-family: Microsoft YaHei;
            font-weight: bold;
            color: rgba(70, 70, 70, 1);
          }
          img {
            width: 213px;
            height: 160px;
          }
          div {
            padding: 8px 5px 0px 4px;
            width: 204px;
            height: 62px;
            font-size: 10px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            color: rgba(82, 82, 82, 1);
            line-height: 16px;
            display: -webkit-box;
            /*! autoprefixer: off */
            -webkit-box-orient: vertical;
            /*! autoprefixer: on */
            -webkit-line-clamp: 4;
            overflow: hidden;
          }
        }
      }
    }

    .show-more {
      position: absolute;
      display: block;
      width: 45px;
      height: 20px;
      top: 10px;
      right: 13px;
      font-size: 11px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(126, 126, 126, 1);
      line-height: 16px;
      padding-right: 10px;
      div {
        position: absolute;
        top: 4px;
        right: -3px;
        background-color: #7e7e7e;
        width: 10px;
        height: 10px;
      }
      div:after {
        content: "";
        width: 7px;
        height: 13px;
        background-color: #ffffff;
        position: absolute;
        top: -4px;
        left: -1px;
        transform: rotate(45deg);
        -ms-transform: rotate(45deg); /* Internet Explorer */
        -moz-transform: rotate(45deg); /* Firefox */
        -webkit-transform: rotate(45deg); /* Safari 和 Chrome */
        -o-transform: rotate(45deg); /* Opera */
      }
    }
  }
  .partner {
    .top {
      margin-top: 23px;
      .item {
        margin-right: 3px;
        width: 97px;
        text-align: center;
        height: 95px;
        position: relative;
        .img-div {
          height: 67px;
          text-align: center;
          line-height: 67px;
        }
        img {
          width: 70%;
        }
        p {
          position: absolute;
          top: 68px;
          width: 90%;
          text-align: center;
          margin: 0 5%;
          font-size: 8px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: rgba(101, 101, 101, 1);
        }
      }
    }
  }
  .goToTop {
    position: fixed;
    bottom: 100px;
    right: 7px;
    width: 26px;
    height: 26px;
  }
  .medicalBox {
    position: fixed;
    bottom: 160px;
    right: 5px;
    width: 40px;
    height: 49px;
    z-index: 100;
  }
  .treasureChest {
    width: 298px;
    .van-col {
      text-align: center;
      height: 96px;
      p {
        font-size: 12px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: rgba(255, 255, 255, 1);
        margin: 0;
      }
      img {
        width: 43px;
        height: 43px;
        margin: 20px 0 0 0;
      }
    }
    .xunwenyisheng {
      background: #93cd9a;
    }
    .service {
      background: #b2aeab;
    }
    .hebao {
      background: #d1badd;
    }
  }
}
</style>
